#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10, LMAX = 1e6 + 10;
int siz[N];
bool vis[N];
bool cmp(int x, int y)
{
    return siz[x] > siz[y];
}
int main()
{
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    int t;
    cin >> t;
    while(t--)
    {
        int d[N], v[N], a[N], ce[N];
        memset(vis, 0, sizeof vis);
        int n, m, L, V;
        bool sur = 1;
        cin >> n >> m >> L >> V;
        for(int i = 1; i <= n; i++)
        {
            cin >> d[i] >> v[i] >> a[i];
            if(a[i] != 0) sur = 0;
        }
        for(int i = 1; i <= m; i++) cin >> ce[i];
        sort(ce + 1, ce + 1 + m);
        if(sur)
        {
            int ans = 0;
            vector<int> g[N];
            for(int i = 1; i <= n; i++)
            {
                if(v[i] > V)
                {
                    ans++;
                    int u = lower_bound(ce + 1, ce + 1 + m, d[i]) - ce;
                    for(; u <= m; u++) g[u].push_back(i);
                }
            }
            cout << ans << " " << m - 1 << endl;
        }
        else
        {
            memset(siz, 0, sizeof siz);
            int fa[N];
            //int op = m;
            vector<int> g[N];
            int ans = 0;
            for(int i = 1; i <= n; i++)
            {
                bool flag = 0;
                for(int j = 1; j <= m; j++)
                {
                    if(d[i] > ce[j]) continue;
                    if((double)sqrt(v[i] * v[i] + 2 * a[i] * (ce[j] - d[i])) > (double)V)
                    {
                        flag = 1;
                        g[j].push_back(i);
                    }
                }
                if(flag) ans++;
            }
            cout << ans << " ";
            for(int i = 1; i <= m; i++) fa[i] = i;
            for(int i = 1; i <= m; i++) siz[i] = g[i].size();
            sort(fa + 1, fa + 1 + m, cmp);
            int ans2 = 0, k = 0;
            bool op = 1;
            for(int i = 1; op == 1 && i <= m; i++)
            {
                bool flag2 = 1;
                for(auto j : g[fa[i]])
                {
                    if(!vis[j])
                    {
                        vis[j] = 1;
                        k++;
                        if(flag2)
                        {
                            flag2 = 0;
                            ans2++;
                        }
                    }
                    if(k == ans)
                    {
                        cout << (m - ans2) << endl;
                        op = 0;
                        break;
                    }
                }
            }
            if(op) cout << (m - ans2) << endl;
        }
    }
    return 0;
}
